package 普通数组;

/**
 * @author tmh
 * @date 2025/3/7 18:27
 * @description
 */
public class T53最大子数组和 {
    public int maxSubArray(int[] nums) {
        int maxSum = nums[0];
        int sum = 0;
        for (int num : nums) {
            sum = Math.max(num, sum + num);
            maxSum = Math.max(sum, maxSum);
        }
        return maxSum;
    }
}
